﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aribaccio
{
    /// <summary>
    /// 定义返回结果[基类]
    /// </summary>
    public class Result
    {
        /// <summary>
        /// 返回信息描述
        /// </summary>
        public string? ResultMsg { get; set; }
        /// <summary>
        /// 返回状态代码
        /// </summary>
        public ResultStatus ResultCode { get; set; }
        /// <summary>
        /// 返回异常消息
        /// </summary>
        public Exception? ResultException { get; set; }
        /// <summary>
        /// 返回执行时长/ms
        /// </summary>
        public long ResultMilliseconds { get; set; }
        /// <summary>
        /// 返回状态[true：成功 false：异常]
        /// </summary>
        public bool ResultState { get { return this.ResultCode == ResultStatus.Succeed && true; } }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public Result()
        {
            this.ResultMsg = string.Empty;
            this.ResultCode = ResultStatus.Succeed;
        }
        /// <summary>
        /// 带参构造函数
        /// </summary>
        /// <param name="argResultMsg">信息描述</param>
        public Result(string argResultMsg)
        {
            this.ResultMsg = argResultMsg;
            this.ResultCode = ResultStatus.Succeed;
        }
        /// <summary>
        /// 带参构造函数
        /// </summary>
        /// <param name="argResultCode">状态代码</param>
        public Result(ResultStatus argResultCode)
        {
            this.ResultMsg = string.Empty;
            this.ResultCode = argResultCode;
        }
        /// <summary>
        /// 带参构造函数
        /// </summary>
        /// <param name="argResultCode">状态代码</param>
        /// <param name="argResultMsg">信息描述</param>
        public Result(ResultStatus argResultCode, string argResultMsg)
        {
            this.ResultMsg = argResultMsg;
            this.ResultCode = argResultCode;
        }
    }
}
